package cn.source.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.GkGradeDoc;
import cn.source.system.service.IGkGradeDocService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 年度一分一档Controller
 * 
 * @author sourcebyte.vip
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/system/gkGradeDoc")
public class GkGradeDocController extends BaseController
{
    @Autowired
    private IGkGradeDocService gkGradeDocService;

    /**
     * 查询年度一分一档列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:list')")
    @GetMapping("/list")
    public TableDataInfo list(GkGradeDoc gkGradeDoc)
    {
        startPage();
        List<GkGradeDoc> list = gkGradeDocService.selectGkGradeDocList(gkGradeDoc);
        return getDataTable(list);
    }

    /**
     * 导出年度一分一档列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:export')")
    @Log(title = "年度一分一档", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GkGradeDoc gkGradeDoc)
    {
        List<GkGradeDoc> list = gkGradeDocService.selectGkGradeDocList(gkGradeDoc);
        ExcelUtil<GkGradeDoc> util = new ExcelUtil<GkGradeDoc>(GkGradeDoc.class);
        util.exportExcel(response, list, "年度一分一档数据");
    }

    /**
     * 获取年度一分一档详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gkGradeDocService.selectGkGradeDocById(id));
    }

    /**
     * 新增年度一分一档
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:add')")
    @Log(title = "年度一分一档", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GkGradeDoc gkGradeDoc)
    {
        return toAjax(gkGradeDocService.insertGkGradeDoc(gkGradeDoc));
    }

    /**
     * 修改年度一分一档
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:edit')")
    @Log(title = "年度一分一档", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GkGradeDoc gkGradeDoc)
    {
        return toAjax(gkGradeDocService.updateGkGradeDoc(gkGradeDoc));
    }

    /**
     * 删除年度一分一档
     */
    @PreAuthorize("@ss.hasPermi('system:gkGradeDoc:remove')")
    @Log(title = "年度一分一档", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gkGradeDocService.deleteGkGradeDocByIds(ids));
    }
}
